<!-- 就业培养 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10">能力测评</p>
    <!-- sonRouter="yybureauFormationBJ" 为跳转新的页面编辑 -->
    <dxtable
      :dataJson="dataJson"
      :portUrl="portUrl"
      :formJson="formJson"
      :qx="qx"
      ref="databale"
      sonRouter="mfhbjpage"
      :extra="{ type: 4 }"
    ></dxtable>
  </div>
</template>
<script lang="ts" setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost } from "../../util/index";
import { NButton, NImage, NTag, NSwitch } from "naive-ui";
import { h, ref, reactive } from "vue";
const databale = ref();
const initeer = () => {
  databale.value.initDataExpose();
};
let dataJson = [
  {
    title: "标题",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "title",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "副标题",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "subheading",
    width: "",
    search: true,
    istable: true,
    required: false,
  },
  {
    title: "封面",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "cover",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "首页推荐",
    search: true,
    type: "select",
    options: [
      {
        label: "全部",
        value: "",
      },
      {
        label: "首页推荐",
        value: "1",
      },
    ],
    key: "recommendation",
    render: (row) => {
      return h(NSwitch, {
        defaultValue: row.recommendation == 1 ? true : false,
        onChange: async (data) => {
          await dxpost(
            portUrl,
            {
              id: row.id,
              recommendation: data ? "1" : "2",
            },
            "put"
          );
          window.$message.success("操作成功！");
        },
      });
    },
  },
  // {
  //     "title": "详情",
  //     "type": "fwb",
  //     "val": "",
  //     "icon": "dx-m-fuwenben",
  //     "span": 24,
  //     "key": "details",
  //     "width": "",
  //     "search": false,
  //     "istable": true,
  //     "required": false
  // }
  {
    title: "排序",
    width: 100,
    render: (row) => {
      row.sjk = "mfh"; //数据库
      row.databaseName = "freakingAwesome"; //表名
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
  {
    title: "添加时间",
    key: "addTime",
    width: 150,
  },
];

const qx = {
  DeletePermissionID: "mfhcapacityEvaluationdel", //删除
  EditPermissionIdentifier: "mfhcapacityEvaluationbj", // 编辑
  NewPermissionIdentifier: "mfhcapacityEvaluationxz", // 新建
  ViewPermissionID: "mfhcapacityEvaluationck", // 查看
};
const portUrl = "mfh/freakingAwesome?type=4";

let formJson = reactive([
  {
    title: "标题",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "title",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "副标题",
    type: "input",
    val: "",
    icon: "dx-shurukuang",
    span: 24,
    key: "subheading",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "封面",
    type: "img",
    val: "",
    icon: "dx-img",
    span: 12,
    key: "cover",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "详情",
    type: "fwb",
    val: "",
    icon: "dx-m-fuwenben",
    span: 24,
    key: "details",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
  {
    title: "标题",
    val: "4",
    icon: "dx-shurukuang",
    span: 24,
    key: "type",
    width: "",
    search: false,
    istable: true,
    required: false,
  },
]);
const czFun = {
  fun: (row) => {
    return [
      h(
        NButton,
        {
          type: "info",
          quaternary: true,
          onClick: async (e) => {},
        },
        "复制代码"
      ),
    ];
  },
};

// 获取字典内容
// const xtgxxmfl = async () => {
//   const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'xtgxxmfl' })
//   dataJson[2].options = [
//     {
//       label: "全部",
//       value: ""
//     },
//     ...data
//   ]
//   formJson[2].options = data
//   xmlxSelect.value = data
//   console.log(data);
// }
// xtgxxmfl()
</script>
<style scoped></style>
